package com.csdn.leon.broadcast;

import java.util.ArrayList;

import com.csdn.leon.base.MyApplication;
import com.csdn.leon.util.TDevice;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class NetBroadcastReceiver  extends BroadcastReceiver{

	public static ArrayList<netEventHandler> mListeners =new ArrayList<NetBroadcastReceiver.netEventHandler>();
	private static String NET_CHANGE_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
	@Override
	public void onReceive(Context context, Intent intent) {
		if(intent.getAction().equals(NET_CHANGE_ACTION)){
			MyApplication.getInstance().isNetWorkConnected =TDevice.isNetworkAvailable();
		    if(mListeners.size()>0){
		    	for(netEventHandler handler:mListeners){
		    		handler.onNetChange();
		    	}
		    }
		
		}
	}

	
	public static abstract interface netEventHandler{
		public abstract void onNetChange();
	}
}
